<div class="ml-microblog-post-options">
    <a href="<?php echo __route('ml-microblog'); ?>" class="ml-microblog-link-home"><?php echo __t('mandrill.microblog.backToHome'); ?></a>
</div>

<?php if (!empty($tag)): ?>
<div class="ml-microblog-tag">
    <?php echo __t('mandrill.microblog.tag.foundPosts', array('tag'=>$tag->tag)); ?>
</div>
<?php endif; ?>

<div class="ml-microblog-posts">
<?php if (!empty($posts)): ?>
    <?php
    $length = 300;
    foreach ($posts as $post){
    ?>
    <div id="<?php echo 'post-'.$post->id; ?>" class="ml-microblog-post">
        <p class="ml-microblog-post-content">
            <?php
            if (strlen($post->html_content) > $length){
                preg_match("/(.{1,$length})\s./ms", $post->html_content, $matches);
                $postContent = $matches[1].'...';
            } else {
                $postContent = $post->html_content;
            }
            $postContent = preg_replace('/(#[a-zA-Z0-9]+)/', '<a href="$1" class="ml-microblog-tag-link">$1</a>', $postContent);
            echo $postContent;
            ?>
            <span class="ml-microblog-post-read-more">
                <a href="#<?php echo 'post-'.$post->id; ?>" class="ml-microblog-link">
                    <?php echo __t('mandrill.microblog.post.readMore'); ?>
                </a>
            </span>
        </p>
        <p class="ml-microblog-post-sub">
            <?php echo __t('mandrill.microblog.post.addedThe'); ?>
            <?php echo date_format($post->date, 'd/m/Y H:i:s'); ?>
            <?php echo __t('mandrill.microblog.post.addedBy'); ?>
            <?php echo $post->profile->user->login; ?>
        </p>
    </div>
    <?php
    }
    ?>
<?php else : ?>
    <div class="ml-microblog-nopost">
        <p><?php echo __t('mandrill.microblog.posts.empty'); ?></p>
    </div>
<?php endif; ?>
</div>